“^”在Microsoft Visual Studio.net2005中是一个什么概念?

来源:百度知道 编辑:UC知道 时间:2024/05/23 02:24:25
以前用过VC6,最近由于工作需要转到Microsoft Visual Studio.net2005上,在这里看到类似
String^ fileName = gcnew String();
之类的东西,这里的“^”表示什么概念?似乎和原来的指针有些类似,但是我发现原来的指针还是可以使用的,那么二者有什么区别?

是c++/cli引入的新的指针。也就类似于安全指针,受gc管理。原来的指针不能指向.net类库里的东西,是指向内存特定位置的,不受管理。

^表示这个对象受.net框架的垃圾回收机制管理

gcnew creates an instance of a managed type (reference or value type) on the garbage collected heap. The result of the evaluation of a gcnew expression is a handle (^) to the type being created.

MSDN上的